///////////////////////////////////////////////////////////////////////////////
///
/// Cylan Client Core
/// Copyright (C) Shenzhen Cylan Tech. Co., Ltd. 2012
///
/// @file       ICABChannel.h
/// @brief      ICAB通道通讯API
///
///////////////////////////////////////////////////////////////////////////////
#ifndef ICAB_CHANNEL_H
#define ICAB_CHANNEL_H

/**
 @typedef ICAB_OPTION_CHANNEL_CALLBACK
 @brief ICAB通道通知回调函数类型
 @warning 回调函数与ICABProcess处于同一线程, 切勿阻塞, 否则会影响ICAB刷新.
 */
typedef void (* ICAB_OPTION_CHANNEL_CALLBACK)(CHANDLE ICAB,
        unsigned short Command,
        unsigned short Serial,
        const unsigned char * const Data,
        int Length);

/**
 @fn CC_STATUS ICABChannelRequestSessionLogoff(CHANDLE ICAB)
 @brief 发送注销操作
 @param ICAB ICAB句柄
 @param Serial 消息序列
 @note 无回复消息
 */
CC_STATUS ICABChannelRequestSessionLogoff(CHANDLE ICAB);


/**
 @fn CC_STATUS ICABChannelRequestSingleSignOn(CHANDLE ICAB, int ResourceID)
 @brief 发送单独登陆请求
 @param ICAB ICAB句柄
 @param ResourceID 单点登录资源ID
 @note 无回复消息
 */
CC_STATUS ICABChannelRequestSingleSignOn(CHANDLE ICAB, int ResourceID);


/**
 @fn CC_STATUS ICABChannelRequestIBOXOpen(CHANDLE ICAB, const char *IBOXPath)
 @brief 发送IBOX远程打开请求
 @param ICAB ICAB句柄
 @param IBOXPath IBOX资源路径
 @note 无回复消息
 */
CC_STATUS ICABChannelRequestIBOXOpen(CHANDLE ICAB, const char *IBOXPath);


/**
 @fn CC_STATUS ICABChannelRequestWinList(CHANDLE ICAB, unsigned short Serial)
 @brief 请求窗口列表
 @param ICAB ICAB句柄
 @param Serial 消息序列
 @note 回复消息结构参考iSession文档
 */
CC_STATUS ICABChannelRequestWinList(CHANDLE ICAB, unsigned short Serial);


/**
 @fn CC_STATUS ICABChannelRequestWinActive(CHANDLE ICAB, unsigned int WinHandle, unsigned int TabHandle)
 @brief 请求切换到窗口
 @param ICAB ICAB句柄
 @param WinHandle 框架窗口句柄。如果标签窗口句柄为0，表示前置框架窗口，不切换Tab窗口
 @param TabHandle 标签窗口句柄。如果标签窗口句柄不为0，则前置框架窗口后，需切换到指定Tab窗口
 @note 无回复消息
 */
CC_STATUS ICABChannelRequestWinActive(CHANDLE ICAB,
                                      unsigned int WinHandle,
                                      unsigned int TabHandle);

/**
 @fn CC_STATUS ICABChannelRequestWinClose(CHANDLE ICAB, unsigned int WinHandle, unsigned int TabHandle)
 @brief 请求关闭窗口
 @param ICAB ICAB句柄
 @param WinHandle 框架窗口句柄。
 @param TabHandle 标签窗口句柄。如果标签窗口句柄为0，表示关闭整个框架窗口。
 @note 如果框架窗口不可见，则忽略
 @note 无回复消息
 */
CC_STATUS ICABChannelRequestWinClose(CHANDLE ICAB,
                                     unsigned int WinHandle,
                                     unsigned int TabHandle);

/**
 @fn CC_STATUS ICABChannelRequestWinCloseAll(CHANDLE ICAB)
 @brief 请求关闭所有窗口
 @param ICAB ICAB句柄
 @note 无回复消息
 */
CC_STATUS ICABChannelRequestWinCloseAll(CHANDLE ICAB);


/**
 @fn CC_STATUS ICABChannelRequestWinCloseForeground(CHANDLE ICAB)
 @brief 请求关闭当前窗口
 @param ICAB ICAB句柄
 @note 无回复消息
 @since ClientCore 3.1
 */
CC_STATUS ICABChannelRequestForegroundWinClose(CHANDLE ICAB);

/**
 @fn CC_STATUS ICABChannelRequestWinCloseForeground(CHANDLE ICAB)
 @brief 请求窗口数量
 @param ICAB ICAB句柄
 @note 无回复消息
 @since ClientCore 3.1
 */
CC_STATUS ICABChannelRequestWndCount(CHANDLE ICAB);

/**
 @fn CC_STATUS ICABChannelRequestWinCloseForeground(CHANDLE ICAB)
 @brief 请求关闭当前桌面
 @param ICAB ICAB句柄
 @note 通道消息有返回, 0 表示成功其他失败
 @since ClientCore 3.1
 */
CC_STATUS ICABChannelCloseCurDesk(CHANDLE ICAB);

/**
 @fn CC_STATUS ICABChannelRequestLaunch(CHANDLE ICAB, unsigned short Serial, int ResourceID)
 @brief 请求已连接的Session启动资源
 @param ICAB 请求运行应用的ICAB句柄
 @param Serial 请求序列号
 @param ResourceID 请求启动的资源ID
 @note 回复启动应用的进程Pid, 具体含义参考iSession文档
 @note 如果应用的应用配置了多个从属启动的程序, 只返回应用本身进程的Pid.
 */
CC_STATUS ICABChannelRequestLaunch(CHANDLE ICAB,
                                   unsigned short Serial,
                                   int ResourceID);

/**
 @fn CC_STATUS ICABChannelRequestLaunchToApplication(CHANDLE ICAB, unsigned short Serial, int ResourceID, char *AppWorkdir, char *AppProgram)
 @brief 请求已连接的Session启动资源
 @param ICAB 请求运行应用的ICAB句柄
 @param Serial 请求序列号
 @param ResourceID 请求启动的资源ID
 @param AppWorkdir 启动应用程序的路径
 @param AppProgram 请求启动的应用程序
 @note 回复启动应用的进程Pid, 具体含义参考iSession文档
 @note 如果应用的应用配置了多个从属启动的程序, 只返回应用本身进程的Pid.
 */
CC_STATUS ICABChannelRequestLaunchToApplication(CHANDLE ICAB,
                                   unsigned short Serial,
                                   int ResourceID,                               
                                   char *AppWorkdir,
                                   char *AppProgram,
                                   char *AppWorkdir1,
                                   char *AppProgram1,
                                   char *AppWorkdir2,
                                   char *AppProgram2,
                                   char *AppWorkdir3,
                                   char *AppProgram3);

/**
 @fn CC_STATUS ICABChannelRequestMinimalAll(CHANDLE ICAB)
 @brief ICAB请求最小化所有可见窗口
 @param ICAB ICAB句柄
 @note 无回复
 */
CC_STATUS ICABChannelRequestMinimalAll(CHANDLE ICAB);

/**
 @fn CC_STATUS ICABChannelMappedIBoxPath(CHANDLE ICAB)
 @brief ICAB向iServer发送iBox映射信息
 @param ICAB ICAB句柄
 @note 无回复
 */
CC_STATUS ICABChannelMappedIBoxPath(CHANDLE ICAB);

/**
 @typedef ICAB_OPTION_RMUSBCHANNEL_CALLBACK
 @brief RMUSB通道通知回调函数类型
 */
typedef void (* ICAB_OPTION_RMUSBCHANNEL_CALLBACK)(CHANDLE ICAB, const unsigned char * const Data,int Length);

/**
 @fn CC_STATUS ICABChannelSendSign(CHANDLE ICAB, const char *SignFilePath)
 @brief ICABChannelSendSign 通道发送签名文件
 @parm ICAB ICAB句柄
 @parm Data 发送的签名路径 png格式
 */
CC_STATUS ICABChannelSendSign(CHANDLE ICAB, const char *SignFilePath);

/**
 @fn CC_STATUS ICABChannelSendKeepTime(CHANDLE ICAB, int ResourceID)
 @brief ICABChannelSendKeepTime 通道发送会话保持时间，会话保持时间由SGA下发
 @parm  ICAB句柄
 @parm ResourceID 资源ID
 */
CC_STATUS ICABChannelSendKeepTime(CHANDLE ICAB, int ResourceID);

/**
 @fn CC_STATUS ICABChannelSendHeartbeat(CHANDLE ICAB)
 @brief ICABChannelSendHeartbeat 通道心跳
 @parm  ICAB句柄
 @retval ERR_SUCCESS 提交成功 
 */
CC_STATUS ICABChannelSendHeartbeat(CHANDLE ICAB);

/**
 @fn CC_STATUS ICABChannelSendHwndMessage(CHANDLE ICAB, int Hwnd, int ptX, int ptY, int Msg, int WParam, int LParam)
 @brief ICABChannelSendHwndMessage 
 @parm  ICAB 句柄
 @parm  Hwnd 消息所属主窗口句柄
 @parm  ptX 光标X坐标
 @parm  ptY 光标Y坐标
 @parm  Msg 消息ID 
 @parm  WParam 消息WPARAM参数 
 @parm  LParam 消息LPARAM参数
 @retval ERR_SUCCESS 提交成功 
 */
CC_STATUS ICABChannelSendHwndMessage(CHANDLE ICAB, int Hwnd, int ptX, int ptY, int Msg, int WParam, int LParam);

/**
 @fn CC_STATUS ICABChannelPostHwndMessage(CHANDLE ICAB, int Hwnd, int ptX, int ptY, int Msg, int WParam, int LParam)
 @brief ICABChannelPostHwndMessage 
 @parm  ICAB 句柄
 @parm  Hwnd 消息所属主窗口句柄
 @parm  ptX 光标X坐标
 @parm  ptY 光标Y坐标
 @parm  Msg 消息ID 
 @parm  WParam 消息WPARAM参数 
 @parm  LParam 消息LPARAM参数
 @retval ERR_SUCCESS 提交成功 
 */
CC_STATUS ICABChannelPostHwndMessage(CHANDLE ICAB, int Hwnd, int ptX, int ptY, int Msg, int WParam, int LParam);

/**
 @fn CC_STATUS ICABHScroll(CHANDLE ICAB, int Length)
 @brief ICABHScroll 发送水平滚动条 
 @parm  ICAB 句柄
 @parm  Length 滚动距离
        滚动行数(1字节)
        正数: 向右滚动
        负数：向左滚动
        0：向右滚动一行
 @retval ERR_SUCCESS 提交成功 
 */
CC_STATUS ICABHScroll(CHANDLE ICAB, int Length);

/**
 @fn CC_STATUS ICABVScroll(CHANDLE ICAB, int Length)
 @brief ICABHScroll 发送垂直滚动条
 @parm  ICAB 句柄
 @parm  Length 滚动距离
        滚动行数(1字节)
        正数: 向下滚动
        负数：向上滚动
        0：向下滚动一行
 @retval ERR_SUCCESS 提交成功 
 */
CC_STATUS ICABVScroll(CHANDLE ICAB, int Length);

/**
 * @fn CC_STATUS ICABChannelSendUnicode(CHANDLE ICAB, unsigned short Code)
 * @brief 发送Unicode字符输入
 * @param ICAB ICAB句柄
 * @param Code 字符的Unicode编码
 * @retval ERR_SUCCESS 发送成功
 * @retval ERR_NETWORK_BLOCK 发送阻塞
 * @warning 返回ERR_NETWORK_BLOCK时, 该操作并未发出.
 */
CC_STATUS ICABChannelSendUnicode(CHANDLE ICAB, unsigned short Code);

#endif /* ICAB_CHANNEL_H */
